package spring.cloud.tasks.api.service;

import spring.cloud.tasks.api.domain.executor.ExecutorInfo;
import spring.cloud.tasks.api.domain.executor.ExecutorRunningInfo;
import spring.cloud.tasks.api.domain.executor.ExecutorTaskItemAssignInfo;

import java.util.List;

public interface ExecutorService {

    /**
     * 获取所有Executors信息；
     */
    List<ExecutorInfo> getExecutorInfoList(String nameSpace);

    /**
     * 获取特定状态的Executors信息；
     */
    List<ExecutorInfo> getExecutorInfoList(String nameSpace, String taskExecutorStatus);

    /**
     * 获取单个Executors信息；
     */
    ExecutorInfo getExecutorInfo(String nameSpace, String executorId);

    /**
     * 获取Executor所分配的分片信息；
     */
    ExecutorTaskItemAssignInfo getExecutorTaskItemAssignInfo(String nameSpace, String executorId);


    /**
     * 获取Executor上所有正在运行的任务分片信息.
     */
    ExecutorRunningInfo getExecutorRunningInfo(String nameSpace, String executorId) throws RuntimeException;

    /**
     * 移除离线的executor.
     */
    void removeExecutor(String nameSpace, String executorId) throws RuntimeException;

    /**
     * 摘取流量
     */
    void extractTraffic(String nameSpace, String executorId) throws RuntimeException;

    /**
     * 恢复流量
     */
    void recoverTraffic(String nameSpace, String executorId) throws RuntimeException;

    /**
     * 重nameSpace域下所有任务分片
     */
    void shardAll(String nameSpace) throws RuntimeException;

    /**
     * 一键restart。
     */
    void restart(String nameSpace, String executorId) throws RuntimeException;
}
